package com.mocha.nezha.graph.example;

import org.apache.hugegraph.driver.GraphManager;
import org.apache.hugegraph.driver.HugeClient;
import org.apache.hugegraph.driver.SchemaManager;
import org.apache.hugegraph.structure.graph.Edge;
import org.apache.hugegraph.structure.graph.Vertex;

import java.util.List;

/**
 * @author songkui
 * @since 2024/3/15 14:13
 */
public class HugeGraphKits {

    public static void main(String[] args) {
        HugeClient hugeClient = HugeClient.builder("http://192.168.50.94:8080", "hugegraph").build();
        SchemaManager schema = hugeClient.schema();
        GraphManager graphManager = hugeClient.graph();
        System.out.println(schema.getPropertyKey("pole_name"));
        System.out.println(schema.getPropertyKey("pole_code"));
        System.out.println(schema.getPropertyKey("line_direction"));

//        schema.removePropertyKey("park_id");
//        schema.removePropertyKey("camera_name");

        System.out.println(schema.getEdgeLabel("line"));
//        schema.removeEdgeLabel("camera_line");

//        schema.removePropertyKey("park_id");
        System.out.println(schema.getVertexLabel("pole"));
//        schema.removeVertexLabel("camera");


//        for (int i =4; i< 11;  i++){
//            Vertex vertex = new Vertex("pole");
//            vertex.id(i+""+i+i);
//            vertex.property("pole_code", "pole0"+i);
//            vertex.property("pole_name", "路段_"+i);
//            graphManager.addVertex(vertex);
//        }

      graphManager.removeEdge("S666>6>>S10");
//        graphManager.removeEdge("S444>6>>S10");
//        graphManager.removeVertex("101010");

//        List<Vertex>  vertexList = graphManager.listVertices();
//        List<Edge>  edgeList = graphManager.listEdges();
//        for (Vertex v : vertexList){
//            System.out.println(v.toString());
//            if (v.id().equals("10")){
//                graphManager.removeVertex(v.id());
//            }
//        }
//
//        for (Edge v : edgeList){
//            System.out.println(v.toString() +"------------"+ v.property("line_direction"));
//            graphManager.removeEdge(v.id());
//        }

//        Map<String, Vertex> vertextMap = vertexList.stream().collect(Collectors.toMap(x -> String.valueOf(x.id()), y->y));
//
//        TraverserManager traverserManager = hugeClient.traverser();
//        List<Path> path = traverserManager.allShortestPaths("9:BBBB", "9:camera026", Direction.OUT, 100);
//
//        for (Path p : path){
//            System.out.println(p);
//        }

    }


}
